<template>
    <el-card class="ep-card" v-show="tianzheng && !hidden" style="margin-bottom:10px">
        <div class="search-content">
            <div class="search-input">
                <epl-search :datas="datas" :tableList="psTableData" :isSearch="isSearch" :api="psUrl" :show="showPerson" :property="person" :type="personType" title="身份证号码" placeholder="请输入身份证号码查询"></epl-search>
                <epl-search :datas="datas" :tableList="cpTableData" :isSearch="isSearch" :api="cpUrl" :show="showCompany" :property="company" :type="companyType" title="统一社会信用代码" placeholder="请输入统一社会信用代码"></epl-search>
            </div>
            <slot></slot>
        </div>
    </el-card>
</template>

<script type="es6">

    export default {
        props: {
            title: {
                type: String,
                default: '请填写title属性'
            },
            hidden: {
                type: Boolean,
                default:false
            },
            person: {},
            company: {},
            psTagType: {
                type: String,
                default:''
            },
            cpTagType: {
                type: String,
                default:''
            },
            showPerson: {
                type: Boolean,
                default:false
            },
            showCompany: {
                type: Boolean,
                default:false
            },
            personType: {
                type: String,
                default: ''
            },
            companyType: {
                type: String,
                default: ''
            },
            datas: {
                type: Object,
                default: null
            },
            isSearch: {
                type: Boolean,
                default:false
            }
        },
        data() {
            return {
                dialogVisible:false,
                tableData:[],
                id:'',
                form:{
                    idCard:'',
                    name:'',
                    paymentStatus:''
                },
                psTableData:[],
                cpTableData:[],
                psUrl:'',
                cpUrl:''
            }
        },
        computed: {
            tianzheng() {
                return !this.$route.query.ticket && !this.$route.query.projid
            }
        },
        watch:{
            psTagType: {
                handler(value) {
                    this.getTableList(value,this.personType);
                },
                deep: true
            },
            cpTagType: {
                handler(value) {
                    this.getTableList(value,this.companyType);
                },
                deep: true
            },
        },
        created() {
            if(this.psTagType){
                this.getTableList(this.psTagType,this.personType);
            }
            if(this.cpTagType){
                this.getTableList(this.cpTagType,this.companyType);
            }
        },
        methods: {
            /**
             * 根据tagType区分逻辑
             */
            getTableList(tag,type){
                let table = [];
                let url = '';
                switch (tag) {
                    case 'COMPANY_SIMPLE_GROUP':
                        table = [
                            // {name:'单位管理码',value:'aab999'},
                            {name:'单位名称',value:'aab069'},
                            {name:'统一社会信用代码',value:'bab010'},
                            {name:'单位类型',value:'aab019'},
                            {name:'单位状态',value:'aaa120'},
                            {name:'当前参保险种',value:'aae140'}
                        ];
                        url = '/business/d100insiup/d01companycommon/CpQueryComm/doCpQueryComm01';
                        break;
                    case 'PERSON_SIMPLE_GROUP':
                        table = [
                            {name:'社会保障号',value:'aac002'},
                            {name:'姓名',value:'aac003'},
                            {name:'性别',value:'aac004'},
                            {name:'出生日期',value:'aac006'},
                            {name:'参加工作时间',value:'aac007'},
                            //{name:'人员管理码',value:'aac999'}
                        ];
                        url = '/business/d100insiup/d02personcommon/PsQueryComm/doPsQueryComm01';
                        break;
                    case 'PERSON_AAB001_GROUP':
                        table = [
                            {name:'社会保障号',value:'aac002'},
                            {name:'姓名',value:'aac003'},
                            {name:'性别',value:'aac004'},
                            {name:'单位名称',value:'aab069'},
                            {name:'缴费险种',value:'aae140'},
                            {name:'参保状态',value:'aac008'},
                            {name:'出生日期',value:'aac006'},
                            //{name:'人员管理码',value:'aac999'},
                        ];
                        url = '/business/d100insiup/d02personcommon/PsQueryComm/doPsQueryComm02';
                        break;
                    case 'PERSON_PENSION_QUERY':
                        table = [
                            {name:'社会保障号',value:'aac002'},
                            {name:'姓名',value:'aac003'},
                            {name:'性别',value:'aac004'},
                            {name:'出生日期',value:'aac006'},
                            {name:'退休时间',value:'aic162'},
                            {name:'退休类型',value:'aic161'},
                            {name:'单位名称',value:'aab069'},
                            // {name:'人员管理码',value:'aac999'},
                        ];
                        url = '/business/d101insib/d01pensioncommon/PensionQueryComm/doPensionQueryComm01';
                        break;
                    case 'PERSON_INJURY_QUERY':
                        table = [
                            {name:'社会保障号',value:'aac002',width:'140'},
                            {name:'姓名',value:'aac003'},
                            {name:'性别',value:'aac004'},
                            {name:'出生日期',value:'aac006'},
                            {name:'工伤类别',value:'alc027'},
                            {name:'工伤发生时间',value:'alc020'},
                            {name:'伤残等级',value:'ala040'},
                            {name:'护理依赖等级',value:'alc060'},
                            {name:'单位名称',value:'aab069'},
                            // {name:'人员管理码',value:'aac999'}
                        ];
                        url = '/business/d102iniii/d01injurycommon/InjuryQueryComm/doInjuryQueryComm01';
                        break;

                    case 'PERSON_SHARE_SOURCE':
                        table = [
                            {name:'姓名',value:'aac003'},
                            {name:'性别',value:'aac004'},
                            {name:'证件类型',value:'aac058'},
                            {name:'证件号码',value:'aac147'},
                            {name:'出生日期',value:'aac006'}
                        ];
                        // url = '/business/d102iniii/d01injurycommon/InjuryQueryComm/doInjuryQueryComm01';
                        break;

                }
                // console.log('table',table);
                if(type.indexOf('PERSON') != '-1'){
                    this.psTableData = table;
                    this.psUrl = url;
                }else if(type.indexOf('COMPANY') != '-1'){
                    this.cpTableData = table;
                    this.cpUrl = url;
                }
            }
        }
    }
</script>

<style lang="less" scoped>
    .search-content{
        display: flex;
        justify-content:space-between;
        .search-input {
            display: flex;
            flex: 1;
            margin-right: 30px;
            span {
                flex: 100px;
                margin-right: 10px;
                line-height: 36px;
                overflow: hidden;
                text-overflow: ellipsis;
                white-space: nowrap;
            }
            span:before {
                content: '*';
                color: #f56c6c;
                margin-right: 4px;
            }

            .el-icon-search {
                cursor: pointer;
            }

            .el-icon-search:hover {
                color: #409eff;
            }
        }
    }
</style>
